package org.test.jiazi_1.common.utils;

import static java.lang.Math.min;
import static org.test.jiazi_1.common.constant.FractionalConstant.*;
import static org.test.jiazi_1.common.constant.GradeConstant.*;


/**
 * @Author: 唐文涛
 * @CreateTime: 2024-11-08
 * @Description: 计算分数
 * @Version: 1.0
 * 说明：通过if-else语句判断成绩等级并计算分数
 * @return 计算后的分数
 * 尽量不要动动这个类，因为这个类是计算分数的核心类，
 * 一旦修改，可能会影响到其他类的计算
 * 所以，尽量不要修改这个类，除非你知道自己在做什么
 * 如果你想修改这个类，最好先备份一下，然后再修改
 * 修改完后，再测试一下，看看是否有问题
 * 如果有问题，再回滚一下
 * 如果没有问题，再提交一下
 * 这样可以保证代码的稳定性
 */
public class NewScoreCalculator {


    //判断分数等级并计算分数
    public static double conversion(double score) {

        score = Math.floor(score);

        if (score >= 100) {
            return score;
        } else if (score >= 95) {
            return 95;
        } else if (score >= 90) {
            return 90;
        } else if (score >= 85) {
            return 85;
        } else if (score >= 80) {
            return 80;
        } else if (score >= 60) {
            return (score % 2 == 0) ? score : score - 1; // 凑整为偶数
        } else if (score >= 10) {
            return Math.floor(score / 10) * 10; // 低于60分，取十位数
        } else {
            return 0; // 低于 10 分
        }
    }


    public static double calculateBMIScore(Double height, Double weight, boolean male) {
        if (height == null || weight == null) return 0;

        double BMI = weight / (height * height / 10000);

        return BMI >= OBESE_BMI ? OBESE :
                BMI >= OVERWEIGHT_BMI ? OVERWEIGHT :
                        BMI >= (male ? NORMAL_BMI_MAN : NORMAL_BMI_WOMAN) ? NORMAL :
                                UNDERWEIGHT;
    }
    public static double calculateOneThousandMeterRunScore(Integer oneThousandMeterRun, boolean isOneTwo) {
        if (oneThousandMeterRun == null || oneThousandMeterRun == 0) {
            return 0;
        }

        // 根据年级获取对应的标准值
        int full = isOneTwo ? FULL_BOY_ONE_THOUSAND_METER_RUN_12 : FULL_BOY_ONE_THOUSAND_METER_RUN_34;
        int excellent = isOneTwo ? EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_12 : EXCELLENT_BOY_ONE_THOUSAND_METER_RUN_34;
        int good = isOneTwo ? GOOD_BOY_ONE_THOUSAND_METER_RUN_12 : GOOD_BOY_ONE_THOUSAND_METER_RUN_34;
        int pass = isOneTwo ? PASS_BOY_ONE_THOUSAND_METER_RUN_12 : PASS_BOY_ONE_THOUSAND_METER_RUN_34;
        int fail = isOneTwo ? FAIL_BOY_ONE_THOUSAND_METER_RUN_12 : FAIL_BOY_ONE_THOUSAND_METER_RUN_34;

        double score;

        if (oneThousandMeterRun <= full) {
            // 满分区间：根据与满分时间的差值计算附加分
            score = FULL + Math.min((full - oneThousandMeterRun) / FOUR, 10);
        } else if (oneThousandMeterRun <= excellent) {
            // 优秀区间：根据具体时间分段
            if (isOneTwo) {
                score = oneThousandMeterRun <= 197 ? 100 : oneThousandMeterRun <= 202 ? 95 : 90;
            } else {
                score = oneThousandMeterRun <= 195 ? 100 : oneThousandMeterRun <= 200 ? 95 : 90;
            }
        } else if (oneThousandMeterRun <= good) {
            // 良好区间
            if (isOneTwo) {
                score = oneThousandMeterRun <= 207 ? 85 : 80;
            } else {
                score = oneThousandMeterRun <= 212 ? 85 : 80;
            }
        } else if (oneThousandMeterRun <= pass) {
            // 及格区间：线性计算
            double passBase = isOneTwo ? PASS_BOY_ONE_THOUSAND_METER_RUN_ONE_12 : PASS_BOY_ONE_THOUSAND_METER_RUN_ONE_34;
            score = PASS + (pass - oneThousandMeterRun) / passBase;
        } else {
            // 不及格区间：线性计算
            double failBase = isOneTwo ? FAIL_BOY_ONE_THOUSAND_METER_RUN_ONE_12 : FAIL_BOY_ONE_THOUSAND_METER_RUN_ONE_34;
            score = FAIL + (fail - oneThousandMeterRun) / failBase;
        }

        return conversion(score);
    }
    /**
     * 计算引体向上成绩
     *
     * @param : pullUps 引体向上成绩
     * @param : isMale 是否为男生
     * @param : isOneTwo 是否为大一/大二
     * @return : 成绩
     * @auther: 唐文涛
     */
    //计算引体向上成绩
    public static double calculatePullUpsScore(Integer pullUps, boolean isOneTwo) {
        if (pullUps == null || pullUps == 0) {
            return 0;
        }

        // 根据年级获取标准值
        int full = isOneTwo ? FULL_BOY_PULL_UPS_12 : FULL_BOY_PULL_UPS_34;
        int excellent = isOneTwo ? EXCELLENT_BOY_PULL_UPS_12 : EXCELLENT_BOY_PULL_UPS_34;
        int good = isOneTwo ? GOOD_BOY_PULL_UPS_12 : GOOD_BOY_PULL_UPS_34;
        int pass = isOneTwo ? PASS_BOY_PULL_UPS_12 : PASS_BOY_PULL_UPS_34;
        int fail = isOneTwo ? FAIL_BOY_PULL_UPS_12 : FAIL_BOY_PULL_UPS_34;

        double score;

        if (pullUps >= full) {
            score = FULL + Math.min((pullUps - full), 10); // 每多1个加1分，最多加10分
        } else if (pullUps >= excellent) {
            // 优秀区间：大二以下18=90, 19=95, 20=100；大二以上19=90, 20=95, 21=100
            int threshold1 = isOneTwo ? 18 : 19;
            int threshold2 = isOneTwo ? 19 : 20;
            score = pullUps >= threshold2 ? 100 : pullUps >= threshold1 ? 95 : 90;
        } else if (pullUps >= good) {
            // 良好区间：大二以下16=80, 17=85；大二以下17=80, 18=85
            int threshold = isOneTwo ? 16 : 17;
            score = pullUps > threshold ? 85 : 80;
        } else if (pullUps >= pass) {
            double passBase = isOneTwo ? PASS_BOY_PULL_UPS_ONE_12 : PASS_BOY_PULL_UPS_ONE_34;
            score = PASS + (pullUps - pass) / passBase;
        } else {
            double failBase = isOneTwo ? FAIL_BOY_PULL_UPS_ONE_12 : FAIL_BOY_PULL_UPS_ONE_34;
            score = FAIL + (pullUps - fail) / failBase;
        }

        return conversion(score);
    }

    /**
     * 计算一分钟仰卧起坐成绩
     *
     * @param oneMinuteSitUps 一分钟仰卧起坐成绩
     * @param isOneTwo        是否为大一/大二
     * @return 成绩
     * @author: 唐文涛
     */
    // 计算一分钟仰卧起坐成绩
    public static double calculateOneMinuteSitUpsScore(Integer oneMinuteSitUps, boolean isOneTwo) {
        if (oneMinuteSitUps == null || oneMinuteSitUps == 0) {
            return 0;
        }

        // 根据年级获取标准值
        int full = isOneTwo ? FULL_GIRL_ONE_MINUTE_SIT_UPS_12 : FULL_GIRL_ONE_MINUTE_SIT_UPS_34;
        int excellent = isOneTwo ? EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_12 : EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_34;
        int good = isOneTwo ? GOOD_GIRL_ONE_MINUTE_SIT_UPS_12 : GOOD_GIRL_ONE_MINUTE_SIT_UPS_34;
        int pass = isOneTwo ? PASS_GIRL_ONE_MINUTE_SIT_UPS_12 : PASS_GIRL_ONE_MINUTE_SIT_UPS_34;
        int fail = isOneTwo ? FAIL_GIRL_ONE_MINUTE_SIT_UPS_12 : FAIL_GIRL_ONE_MINUTE_SIT_UPS_34;

        double score;

        if (oneMinuteSitUps >= full) {
            // 满分区间：超过满分个数按不同规则加分
            int extra = oneMinuteSitUps - full;
            score = FULL + Math.min(extra > 6 ? extra - THREE : extra / TWO, 10);
        } else if (oneMinuteSitUps >= excellent) {
            double excelBase = isOneTwo ? EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : EXCELLENT_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = EXCELLENT + (oneMinuteSitUps - excellent) / excelBase;
        } else if (oneMinuteSitUps >= good) {
            double goodBase = isOneTwo ? GOOD_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : GOOD_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = GOOD + (oneMinuteSitUps - good) / goodBase;
        } else if (oneMinuteSitUps >= pass) {
            double passBase = isOneTwo ? PASS_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : PASS_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = PASS + (oneMinuteSitUps - pass) / passBase;
        } else {
            double failBase = isOneTwo ? FAIL_GIRL_ONE_MINUTE_SIT_UPS_ONE_12 : FAIL_GIRL_ONE_MINUTE_SIT_UPS_ONE_34;
            score = FAIL + (oneMinuteSitUps - fail) / failBase;
        }

        return conversion(score);
    }
    /**
     * 计算800米跑成绩
     *
     * @param eightHundredMeterRun 800米跑成绩     是否为男生
     * @param isOneTwo             是否为大一/大二
     * @return 成绩
     */
    // 计算八百米跑步成绩
    public static double calculateEightHundredMeterRunScore(Integer eightHundredMeterRun, boolean isOneTwo) {


        Integer full = isOneTwo ? FULL_GIRL_EIGHT_HUNDRED_METER_RUN_12 : FULL_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer excellent = isOneTwo ? EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_12 :
                EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer good = isOneTwo ? GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_12 : GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer pass = isOneTwo ? PASS_GIRL_EIGHT_HUNDRED_METER_RUN_12 : PASS_GIRL_EIGHT_HUNDRED_METER_RUN_34;
        Integer fail = isOneTwo ? FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_12 : FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_34;

        if (eightHundredMeterRun == null) {
            return 0;
        }
        if (eightHundredMeterRun == 0) {
            return 0;
        }
        // 判断成绩等级并计算分数
        double score;
        if (eightHundredMeterRun <= full) {
            score = FULL + min((full - eightHundredMeterRun) / FIVE, 10);
        } else if (eightHundredMeterRun <= excellent) {
            Double excelBase = isOneTwo ? EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 :
                    EXCELLENT_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = EXCELLENT + (excellent - eightHundredMeterRun) / excelBase;
        } else if (eightHundredMeterRun <= good) {
            Double goodBase = isOneTwo ? GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 :
                    GOOD_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = GOOD + (good - eightHundredMeterRun) / goodBase;
        } else if (eightHundredMeterRun <= pass) {
            Double passBase = isOneTwo ? PASS_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 :
                    PASS_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = PASS + (pass - eightHundredMeterRun) / passBase;
        } else {
            Double failBase = isOneTwo ? FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_12 :
                    FAIL_GIRL_EIGHT_HUNDRED_METER_RUN_ONE_34;
            score = FAIL + (fail - eightHundredMeterRun) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算坐位体前屈成绩
     *
     * @param sitAndReach 坐位体前屈成绩
     * @param isMale      是否为男生
     * @param isOneTwo    是否为大一/大二
     * @author: 唐文涛
     */
    //// 计算坐位体前屈成绩
    public static double calculateSitAndReachScore(Double sitAndReach, boolean isMale, boolean isOneTwo) {

        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_SIT_AND_REACH_12 : EXCELLENT_BOY_SIT_AND_REACH_34) :
                (isOneTwo ? EXCELLENT_GIRL_SIT_AND_REACH_12 : EXCELLENT_GIRL_SIT_AND_REACH_34);
        Double good = isMale ? (isOneTwo ? GOOD_BOY_SIT_AND_REACH_12 : GOOD_BOY_SIT_AND_REACH_34) : (isOneTwo ?
                GOOD_GIRL_SIT_AND_REACH_12 : GOOD_GIRL_SIT_AND_REACH_34);
        Double pass = isMale ? (isOneTwo ? PASS_BOY_SIT_AND_REACH_12 : PASS_BOY_SIT_AND_REACH_34) : (isOneTwo ?
                PASS_GIRL_SIT_AND_REACH_12 : PASS_GIRL_SIT_AND_REACH_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_SIT_AND_REACH_12 : FAIL_BOY_SIT_AND_REACH_34) : (isOneTwo ?
                FAIL_GIRL_SIT_AND_REACH_12 : FAIL_GIRL_SIT_AND_REACH_34);

        if (sitAndReach == null) {
            return 0;
        }
        // 判断成绩等级并计算分数
        double score;
        if (sitAndReach >= excellent) {
            if (isMale) {
                if (isOneTwo) {
                    score = sitAndReach >= 23.1 ? sitAndReach >= 24.9 ? 100 : 95 : 90;
                } else {
                    score = sitAndReach >= 23.3 ? sitAndReach >= 25.1 ? 100 : 95 : 90;
                }
            } else {
                if (isOneTwo) {
                    score = sitAndReach >= 24 ? sitAndReach >= 25.8 ? 100 : 95 : 90;
                } else {
                    score = sitAndReach >= 24.4 ? sitAndReach >= 26.3 ? 100 : 95 : 90;
                }
            }
        } else if (sitAndReach >= good) {
            Double goodBase = isMale ? (isOneTwo ? GOOD_BOY_SIT_AND_REACH_ONE_12 : GOOD_BOY_SIT_AND_REACH_ONE_34) :
                    (isOneTwo ? GOOD_GIRL_SIT_AND_REACH_ONE_12 : GOOD_GIRL_SIT_AND_REACH_ONE_34);
            score = GOOD + (sitAndReach - good) / goodBase;
        } else if (sitAndReach >= pass) {
            Double passBase = isMale ? (isOneTwo ? PASS_BOY_SIT_AND_REACH_ONE_12 : PASS_BOY_SIT_AND_REACH_ONE_34) :
                    (isOneTwo ? PASS_GIRL_SIT_AND_REACH_ONE_12 : PASS_GIRL_SIT_AND_REACH_ONE_34);
            score = PASS + (sitAndReach - pass) / passBase;
        } else {
            Double failBase = isMale ? (isOneTwo ? FAIL_BOY_SIT_AND_REACH_ONE_12 : FAIL_BOY_SIT_AND_REACH_ONE_34) :
                    (isOneTwo ? FAIL_GIRL_SIT_AND_REACH_ONE_12 : FAIL_GIRL_SIT_AND_REACH_ONE_34);
            score = FAIL + (sitAndReach - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /***
     * 计算立定跳远成绩
     * @auther: 唐文涛
     * @param standingLongJump  立定跳远成绩
     * @param isMale 是否为男生
     * @param isOneTwo 是否为大一/大二
     * @return 成绩
     */
    public static double calculateStandingLongJumpScore(Double standingLongJump, boolean isMale, boolean isOneTwo) {
        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_STANDING_LONG_JUMP_12 :
                EXCELLENT_BOY_STANDING_LONG_JUMP_34) : (isOneTwo ? EXCELLENT_GIRL_STANDING_LONG_JUMP_12 :
                EXCELLENT_GIRL_STANDING_LONG_JUMP_34);
        Double good = isMale ? (isOneTwo ? GOOD_BOY_STANDING_LONG_JUMP_12 : GOOD_BOY_STANDING_LONG_JUMP_34)
                : (isOneTwo ? GOOD_GIRL_STANDING_LONG_JUMP_12 : GOOD_GIRL_STANDING_LONG_JUMP_34);
        Double pass = isMale ? (isOneTwo ? PASS_BOY_STANDING_LONG_JUMP_12 : PASS_BOY_STANDING_LONG_JUMP_34) :
                (isOneTwo ? PASS_GIRL_STANDING_LONG_JUMP_12 : PASS_GIRL_STANDING_LONG_JUMP_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_STANDING_LONG_JUMP_12 : FAIL_BOY_STANDING_LONG_JUMP_34) :
                (isOneTwo ? FAIL_GIRL_STANDING_LONG_JUMP_12 : FAIL_GIRL_STANDING_LONG_JUMP_34);

        if (standingLongJump == null) {
            return 0;
        }
        // 判断成绩等级并计算分数
        double score;
        if (standingLongJump >= excellent) {
            if (isMale) {
                if (isOneTwo) {
                    score = standingLongJump >= 268 ? standingLongJump >= 273 ? 100 : 95 : 90;
                } else {
                    score = standingLongJump >= 270 ? standingLongJump >= 275 ? 100 : 95 : 90;
                }
            } else {
                if (isOneTwo) {
                    score = standingLongJump >= 201 ? standingLongJump >= 207 ? 100 : 95 : 90;
                } else {
                    score = standingLongJump >= 202 ? standingLongJump >= 208 ? 100 : 95 : 90;
                }
            }
        } else if (standingLongJump >= good) {

            if (isMale) {
                if (isOneTwo) {
                    score = standingLongJump >= 256 ? 85 : 80;
                } else {
                    score = standingLongJump >= 258 ? 85 : 80;
                }
            } else {
                if (isOneTwo) {
                    score = standingLongJump >= 188 ? 85 : 80;
                } else {
                    score = standingLongJump >= 189 ? 85 : 80;
                }
            }
        } else if (standingLongJump >= pass) {
            Double passBase = isMale ? (isOneTwo ? PASS_BOY_STANDING_LONG_JUMP_ONE_12 :
                    PASS_BOY_STANDING_LONG_JUMP_ONE_34) : (isOneTwo ? PASS_GIRL_STANDING_LONG_JUMP_ONE_12 :
                    PASS_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = PASS + (standingLongJump - pass) / passBase;
        } else {
            Double failBase = isMale ? (isOneTwo ? FAIL_BOY_STANDING_LONG_JUMP_ONE_12 :
                    FAIL_BOY_STANDING_LONG_JUMP_ONE_34) : (isOneTwo ? FAIL_GIRL_STANDING_LONG_JUMP_ONE_12 :
                    FAIL_GIRL_STANDING_LONG_JUMP_ONE_34);
            score = FAIL + (standingLongJump - fail) / failBase;
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算50米跑成绩
     *
     * @param fiftyMeterRun 50米跑成绩
     * @param isMale        是否为男生
     * @param isOneTwo      是否为大一/大二
     * @return 成绩
     * @author: 唐文涛
     */

    public static double calculateFiftyMeterRunScore(Double fiftyMeterRun, boolean isMale, boolean isOneTwo) {
        // 定义基准时间和基准分
        Double excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_FIFTY_METER_RUN_12 : EXCELLENT_BOY_FIFTY_METER_RUN_34)
                : (isOneTwo ? EXCELLENT_GIRL_FIFTY_METER_RUN_12 : EXCELLENT_GIRL_FIFTY_METER_RUN_34);
        Double good = isMale ? (isOneTwo ? GOOD_BOY_FIFTY_METER_RUN_12 : GOOD_BOY_FIFTY_METER_RUN_34) : (isOneTwo ?
                GOOD_GIRL_FIFTY_METER_RUN_12 : GOOD_GIRL_FIFTY_METER_RUN_34);
        Double pass = isMale ? (isOneTwo ? PASS_BOY_FIFTY_METER_RUN_12 : PASS_BOY_FIFTY_METER_RUN_34) : (isOneTwo ?
                PASS_GIRL_FIFTY_METER_RUN_12 : PASS_GIRL_FIFTY_METER_RUN_34);
        Double fail = isMale ? (isOneTwo ? FAIL_BOY_FIFTY_METER_RUN_12 : FAIL_BOY_FIFTY_METER_RUN_34) : (isOneTwo ?
                FAIL_GIRL_FIFTY_METER_RUN_12 : FAIL_GIRL_FIFTY_METER_RUN_34);

        if (fiftyMeterRun == null) {
            return 0;
        }
        if (fiftyMeterRun == 0) {
            return 0;
        }
        // 判断成绩等级并计算分数
        double score;
        if (fiftyMeterRun <= excellent) {
            if (isMale) {
                if (isOneTwo) {
                    score = fiftyMeterRun <= 6.8 ? fiftyMeterRun <= 6.7 ? 100 : 95 : 90;
                } else {
                    score = fiftyMeterRun <= 6.7 ? fiftyMeterRun <= 6.6 ? 100 : 95 : 90;
                }
            } else {
                if (isOneTwo) {
                    score = fiftyMeterRun <= 7.6 ? fiftyMeterRun <= 7.5 ? 100 : 95 : 90;
                } else {
                    score = fiftyMeterRun <= 7.5 ? fiftyMeterRun <= 7.4 ? 100 : 95 : 90;
                }
            }
        } else if (fiftyMeterRun <= good) {
            if (isMale) {
                if (isOneTwo) {
                    score = fiftyMeterRun <= 7 ? 85 : 80;
                } else {
                    score = fiftyMeterRun <= 6.9 ? 85 : 80;
                }
            } else {
                if (isOneTwo) {
                    score = fiftyMeterRun <= 8 ? 85 : 80;
                } else {
                    score = fiftyMeterRun <= 7.9 ? 85 : 80;
                }
            }
        } else if (fiftyMeterRun <= pass) {
            Double passBase = isMale ?
                    (isOneTwo ? PASS_BOY_FIFTY_METER_RUN_ONE_12 : PASS_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ?
                    PASS_GIRL_FIFTY_METER_RUN_ONE_12 : PASS_GIRL_FIFTY_METER_RUN_ONE_34);
            score = PASS + Math.round((pass - fiftyMeterRun) / passBase);
        } else {
            Double failBase = isMale ?
                    (isOneTwo ? FAIL_BOY_FIFTY_METER_RUN_ONE_12 : FAIL_BOY_FIFTY_METER_RUN_ONE_34) : (isOneTwo ?
                    FAIL_GIRL_FIFTY_METER_RUN_ONE_12 : FAIL_GIRL_FIFTY_METER_RUN_ONE_34);
            score = FAIL + Math.round((fail - fiftyMeterRun) / failBase);
        }
        // 四舍五入到最接近的整数
        return conversion(score);
    }

    /**
     * 计算肺活量成绩
     *
     * @param lungCapacity 肺活量
     * @param isMale       是否为男生
     * @param isOneTwo     是否为大一/大二
     * @return 成绩
     * @author 唐文涛
     */
    public static double calculateLungCapacityScore(Double lungCapacity, boolean isMale, boolean isOneTwo) {
        // 确定基准值和分数常量
        Integer excellent = isMale ? (isOneTwo ? EXCELLENT_BOY_LUNG_CAPACITY_12 : EXCELLENT_BOY_LUNG_CAPACITY_34) :
                (isOneTwo ? EXCELLENT_GIRL_LUNG_CAPACITY_12 : EXCELLENT_GIRL_LUNG_CAPACITY_34);
        Integer good = isMale ? (isOneTwo ? GOOD_BOY_LUNG_CAPACITY_12 : GOOD_BOY_LUNG_CAPACITY_34) : (isOneTwo ?
                GOOD_GIRL_LUNG_CAPACITY_12 : GOOD_GIRL_LUNG_CAPACITY_34);
        Integer pass = isMale ? (isOneTwo ? PASS_BOY_LUNG_CAPACITY_12 : PASS_BOY_LUNG_CAPACITY_34) : (isOneTwo ?
                PASS_GIRL_LUNG_CAPACITY_12 : PASS_GIRL_LUNG_CAPACITY_34);
        Integer fail = isMale ? (isOneTwo ? FAIL_BOY_LUNG_CAPACITY_12 : FAIL_BOY_LUNG_CAPACITY_34) : (isOneTwo ?
                FAIL_GIRL_LUNG_CAPACITY_12 : FAIL_GIRL_LUNG_CAPACITY_34);
        // 计算成绩
        if (lungCapacity == null) {
            return 0;
        }

        double score;
        if (lungCapacity >= excellent) {
            if (isMale) {
                if (isOneTwo) {
                    score = lungCapacity >= 4920 ? lungCapacity >= 5040 ? 100 : 95 : 90;
                } else {
                    score = lungCapacity >= 5020 ? lungCapacity >= 5140 ? 100 : 95 : 90;
                }
            } else {
                if (isOneTwo) {
                    score = lungCapacity >= 3350 ? lungCapacity >= 3400 ? 100 : 95 : 90;
                } else {
                    score = lungCapacity >= 3400 ? lungCapacity >= 3450 ? 100 : 95 : 90;
                }
            }
        } else if (lungCapacity >= good) {
            if (isMale) {
                if (isOneTwo) {
                    score = lungCapacity >= 4550 ? 85 : 80;
                } else {
                    score = lungCapacity >= 4650 ? 85 : 80;
                }
            } else {
                if (isOneTwo) {
                    score = lungCapacity >= 3150 ? 85 : 80;
                } else {
                    score = lungCapacity >= 3200 ? 85 : 80;
                }
            }
        } else if (lungCapacity >= pass) {
            Integer passBase = isMale ? (isOneTwo ? PASS_BOY_LUNG_CAPACITY_ONE_12 : PASS_BOY_LUNG_CAPACITY_ONE_34) :
                    (isOneTwo ? PASS_GIRL_LUNG_CAPACITY_ONE_12 : PASS_GIRL_LUNG_CAPACITY_ONE_34);
            score = PASS + (lungCapacity - pass) / passBase;
        } else {
            Integer failBase = isMale ? (isOneTwo ? FAIL_BOY_LUNG_CAPACITY_ONE_12 : FAIL_BOY_LUNG_CAPACITY_ONE_34) :
                    (isOneTwo ? FAIL_GIRL_LUNG_CAPACITY_ONE_12 : FAIL_GIRL_LUNG_CAPACITY_ONE_34);
            score = FAIL + (lungCapacity - fail) / failBase;
        }

        return conversion(score);
    }
}